package com.yxym.enum_;

public class EnumMethod {
    public static void main(String[] args) {
        //使用Season2 枚举类来演示各种方法
        Season2 spring  = Season2.SPRING;
        //输出枚举对象的名字
        System.out.println(spring.name());
        //ordinal()输出的是该枚举对象的次序/编号，从0开始编号
        //SPRING枚举对象是第三个，因此输出0
        System.out.println(spring.ordinal());
        //从反编译可以看出values方法返回是数组Season2[]
        Season2[] values = Season2 .values();
        for (Season2 season: values){//增强for循环
            System.out.println(season);
        }
        Season2 spring1 = Season2.valueOf("SPRING");
        System.out.println("spring1=" + spring1);
        System.out.println(spring == spring1);
        System.out.println(Season2.SPRING.compareTo(Season2.WINTER));
        System.out.println(Season2.WINTER.compareTo(Season2.SPRING));
     }
}